@font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
  'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
  sans-serif;
@code-font-family: 'Consolas', 'Monaco', 'Courier New', monospace;

// 颜色变量
@primary-color: #1890ff;
@primary-color-hover: #40a9ff;
@text-color: #333333;
@text-color-secondary: #666666;
@border-color: #d9d9d9;
@background-color: #f0f2f5;
@white: #ffffff;
@black: #000000;
@gray: #ababab;

// 暗黑模式颜色
@dark-bg: #141414;
@dark-bg-secondary: #1f1f1f;
@dark-bg-tertiary: #2d2d2d;
@dark-text: #ffffff;
@dark-text-secondary: #cccccc;
@dark-text-tertiary: #aaaaaa;

// 滚动条样式
@scrollbar-width: 8px;
@scrollbar-track-bg: #f1f1f1;
@scrollbar-thumb-bg: #c1c1c1;
@scrollbar-thumb-hover-bg: #a8a8a8;
@dark-scrollbar-track-bg: #2d2d2d;
@dark-scrollbar-thumb-bg: #555555;
@dark-scrollbar-thumb-hover-bg: #666666;

// ===========================================================
// 基础样式
// ===========================================================

// 通用样式重置
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  font-family: @font-family;
  line-height: 1.5;
  font-weight: 400;

  color: @text-color;
  background-color: @background-color;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
}

#app {
  width: 100%;
  min-height: 100vh;
}

// 链接样式
a {
  color: @primary-color;
  text-decoration: none;
  transition: color 0.3s ease;

  &:hover {
    color: @primary-color-hover;
    text-decoration: underline;
  }
}

// 标题样式
h1,
h2,
h3,
h4,
h5,
h6 {
  color: #262626;
  margin-bottom: 0.5em;
  font-weight: 500;
}

h1 {
  font-size: 2em;
}

h2 {
  font-size: 1.5em;
}

h3 {
  font-size: 1.25em;
}

h4 {
  font-size: 1em;
}

h5 {
  font-size: 0.875em;
}

h6 {
  font-size: 0.75em;
}

// 按钮样式覆盖
.ant-btn {
  font-family: @font-family;
  border-radius: 2px;
}

// 输入框样式覆盖
.ant-input {
  font-family: @font-family;
  border-radius: 2px;
}

// 卡片样式覆盖
.ant-card {
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

// 表格样式覆盖
.ant-table {
  font-family: @font-family;
}

// 表单样式覆盖
.ant-form {
  font-family: @font-family;
}

// 布局容器样式
.admin-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-header {
  height: 64px;
  background-color: @white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  z-index: 100;
  padding: 0 24px;
}

.admin-content {
  flex: 1;
  padding: 24px;
  background-color: @background-color;
  min-height: 0;
}

// 菜单样式
.sider-menu {
  .ant-menu-item {
    height: 40px;
    line-height: 40px;
    margin: 4px 0;
    transition: all 0.3s ease;
    border-radius: 6px;

    &:hover {
      background-color: #f0f9ff;
    }

    &.ant-menu-item-selected {
      background-color: #e6f7ff;
      color: @primary-color;

      &:hover {
        background-color: #bae7ff;
      }
    }
  }

  .ant-menu-item-active {
    color: @primary-color;
  }
}

/* WebKit 滚动条 */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 6px;
}

::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
  background: #999;
}

::-webkit-scrollbar-corner {
  background: #f0f0f0;
}

// 响应式布局
@media (max-width: 768px) {
  .admin-content {
    padding: 16px;
  }
}

// ===========================================================
// 暗黑模式全局样式
// ===========================================================

.dark-mode {
  // 基础颜色
  color: @dark-text;
  background-color: @dark-bg;

  // 滚动条样式
  ::-webkit-scrollbar-track {
    background-color: @dark-scrollbar-track-bg;
  }

  ::-webkit-scrollbar-thumb {
    background-color: @dark-scrollbar-thumb-bg;

    &:hover {
      background-color: @dark-scrollbar-thumb-hover-bg;
    }
  }



  // 链接样式
  a {
    color: @primary-color;

    &:hover {
      color: @primary-color-hover;
    }
  }

  // 标题样式
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    color: @dark-text;
  }

  // 布局容器样式
  .admin-layout {
    background-color: @dark-bg;
  }

  .admin-header {
    background-color: @dark-bg-secondary !important;
    background: @dark-bg-secondary !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid #333;
  }

  .header-content,
  .system-settings-container,
  .dashboard-container {
    background-color: @dark-bg-secondary !important;
  }

  .dashboard-header {
    background-color: @dark-bg-secondary !important;
    border: 1px solid #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  .article-list-header,
  .category-list-header,
  .tag-list-header,
  .personal-info-header,
  .system-settings-header,
  .dashboard-container {

    h2,
    h3,
    h4,
    h5,
    h6 .stat-value {
      color: @dark-text !important;
    }
  }

  .admin-content {
    background-color: @dark-bg;
  }

  .content-wrapper {
    background-color: @dark-bg-secondary !important;
    color: @dark-text;
    border: 1px solid #333;
  }

  // 按钮样式覆盖
  .ant-btn {
    &:is(.ant-btn-primary) {
      background-color: #255f88;
      border-color: #255f88;
      color: #fff !important;

      &:hover {
        background-color: #255f88;
        border-color: #255f88;
      }
    }

    &:not(.ant-btn-primary):not(.ant-btn-success):not(.ant-btn-warning):not(.ant-btn-danger) {
      background-color: @dark-bg-tertiary;
      border-color: #444;
      color: rgba(229, 224, 216, 0.85) !important;

      &:hover {
        background-color: #3a3a3a;
        border-color: #555;
      }
    }
  }

  // 输入框样式覆盖
  .ant-input,
  .ant-input-number,
  .ant-input-affix-wrapper {
    background-color: @dark-bg-tertiary !important;
    border-color: #444 !important;
    color: @dark-text !important;

    input {
      color: @dark-text !important;
    }

    &:hover {
      border-color: #555 !important;
    }

    &:focus {
      border-color: @primary-color !important;
    }
  }


  button {
    .anticon {
      color: rgba(229, 224, 216, 0.85) !important;
    }
  }


  .ant-select-selection-search,
  .ant-select-selection-placeholder,
  .ant-select-selection-search-input::placeholder,
  .ant-input::placeholder,
  .ant-picker-input>input::placeholder {
    color: rgb(191, 184, 173) !important;
  }

  .ant-select-clear {
    color: rgba(229, 224, 216, 0.25) !important;
    background-image: initial !important;
    background-color: rgb(36, 37, 37) !important;
  }

  .ant-select-selection-item {
    color: rgba(229, 224, 216, 0.85) !important;
  }

  .ant-picker,
  .ant-picker-range,
  .ant-picker-panel {
    background-color: @dark-bg-tertiary !important;
    border-color: #444 !important;
    color: @dark-text !important;

    .ant-picker-header button {
      color: #e5e0d840 !important;
    }

    .ant-picker-header-view button {
      color: #e5e0d8d9 !important;
    }

    .ant-picker-content {
      thead tr th {
        color: rgba(229, 224, 216, 0.85) !important;
      }
    }

    .ant-picker-cell {
      color: #e5e0d840 !important;

      &.ant-picker-cell-in-view {
        color: rgb(229 224 216 / 85%) !important;
      }
    }

  }

  // 卡片样式覆盖
  .ant-card {
    background-color: @dark-bg-secondary !important;
    border: 1px solid #333 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;

    .ant-card-head {
      border-bottom: 1px solid #333;

      .ant-card-head-title {
        color: @dark-text;
      }
    }

    .ant-card-body {
      color: @dark-text-secondary !important;

      .article-list-toolbar {
        background-color: @dark-bg-secondary !important;
        color: @dark-text;
        border-bottom: 1px solid @dark-bg-secondary;
      }

      .stat-info {
        color: @dark-text;

        .stat-value {
          color: @dark-text;
        }
      }
    }
  }



  .editor-wrapper {
    .v-md-editor__preview-wrapper {
      background-color: #2d2d2d !important;

      .github-markdown-body div {
        background-color: #2d2d2d !important;
      }

      .github-markdown-body pre code,
      .github-markdown-body pre tt {
        background-color: #2d2d2d !important;
        color: #aaaaaa;
      }

      .v-md-editor-preview {
        background-color: #2d2d2d !important;
        color: #aaaaaa;
      }
    }

    .v-md-editor__toolbar {
      background-color: #2d2d2d !important;

      .v-md-editor__toolbar-item {
        color: #aaaaaa;
      }
    }

    .v-md-editor__toolbar-item--active,
    .v-md-editor__toolbar-item--active:hover {
      background: #444 !important;
    }

    .v-md-editor__main {
      background-color: #2d2d2d !important;

      .v-md-textarea-editor textarea {
        background-color: #2d2d2d !important;
        color: @dark-text;
      }
    }

    .v-md-editor__editor-wrapper {
      border-right: 1px solid #444 !important;
    }

    .v-md-editor__toolbar {
      border-bottom: 1px solid #444 !important;
    }
  }

  .editor-wrapper:hover {
    border-color: #aaaaaa !important;
  }

  // 图床管理页面样式
  .image-bed-container {
    .header-left h2 {
      color: @dark-text !important;
    }

    .header-subtitle {
      color: @dark-text-tertiary !important;
    }

    .upload-button {
      background-color: #255f88 !important;
      border-color: #255f88 !important;
    }

    .image-card {
      background-color: @dark-bg-secondary !important;
      border: 1px solid #333 !important;

      .image-bed-toolbar {
        background-color: @dark-bg-secondary !important;
        border-bottom: 1px solid #333 !important;
      }

      .content-area {
        background-color: @dark-bg-secondary !important;
      }
    }

    .image-item {
      background-color: @dark-bg-tertiary !important;
      border-color: #444 !important;

      .image-name {
        color: @dark-text !important;
      }

      .image-meta {
        color: @dark-text-tertiary !important;
      }

      &.selected {
        background-color: #255f88 !important;
        border-color: @primary-color !important;
      }
    }

    .image-wrapper {
      background-color: #3a3a3a !important;
    }

    .image-table {
      .ant-table-thead>tr>th {
        background-color: @dark-bg-tertiary !important;
        border-bottom-color: #333 !important;
        color: @dark-text !important;
      }

      .ant-table-tbody>tr>td {
        border-bottom-color: #333 !important;
        color: @dark-text-secondary !important;
      }

      .ant-table-tbody>tr:hover>td {
        background-color: #3a3a3a !important;
      }

      .image-name-cell {
        .image-name {
          color: @dark-text !important;
        }

        .image-meta-small {
          color: @dark-text-tertiary !important;
        }
      }
    }

    // 弹窗样式
    .upload-modal-content,
    .detail-modal-content,
    .edit-modal-content {
      .ant-modal-header {
        background-color: @dark-bg-secondary !important;
        border-bottom-color: #333 !important;
      }

      .ant-modal-title {
        color: @dark-text !important;
      }

      .ant-modal-body {
        background-color: @dark-bg-secondary !important;
        color: @dark-text !important;
      }

      .ant-modal-footer {
        background-color: @dark-bg-secondary !important;
        border-top-color: #333 !important;
      }

      .detail-image-wrapper {
        background-color: @dark-bg-tertiary !important;
      }

      .detail-info h3 {
        color: @dark-text !important;
      }

      .meta-label {
        color: @dark-text !important;
      }

      .meta-value {
        color: @dark-text-secondary !important;
      }
    }
  }

  .ant-page-header {
    .ant-page-header-heading {

      .ant-page-header-back .ant-page-header-back-button,
      .ant-page-header-heading-title {
        color: @dark-text;
      }

      .ant-page-header-heading-sub-title {
        color: #aaaaaa;
      }
    }
  }

  .enhanced-select,
  .enhanced-textarea {
    border: 1px solid #444 !important;
  }


  .enhanced-select:hover {
    border-color: #aaaaaa !important;
  }

  .enhanced-textarea:hover {
    border-color: #aaaaaa !important;
  }

  .enhanced-textarea:focus {
    border-color: #aaaaaa !important;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
  }

  .sider-trigger {
    background-color: @dark-bg-secondary !important;

    .anticon {
      color: @dark-text !important;
    }
  }

  // 表格样式覆盖
  .ant-table {
    background-color: @dark-bg-secondary;

    .anticon {
      color: #e5e0d840 !important;
    }

    .ant-table-content {
      background-color: @dark-bg-secondary;
    }

    .ant-table-container {
      background-color: @dark-bg-secondary;
      border: 1px solid #333;
    }

    .ant-table-thead>tr>th {
      background-color: @dark-bg-tertiary;
      border-bottom: 1px solid #333;
      color: @dark-text;

      .ant-table-column-title {
        color: rgba(229, 224, 216, 0.85);
      }
    }

    .ant-table-column-has-sorters:hover {
      background-color: @dark-bg-secondary !important;
    }

    .ant-table-tbody>tr {
      border-bottom: 1px solid #333;
    }

    .ant-table-tbody>tr>td {
      background-color: @dark-bg-secondary;
      color: rgba(229, 224, 216, 0.85);

      .article-title-link,
      .category-name {
        color: rgba(229, 224, 216, 0.85);
      }
    }

    .ant-table-tbody>tr:hover>td {
      background-color: #2a2a2a;
    }

    .ant-table-cell {
      .ant-tag {
        color: rgba(229, 224, 216, 0.85);
        list-style-image: initial;
        background-image: initial;
        background-color: rgb(39, 40, 39);
        border-color: rgb(69, 72, 71);
      }
    }
  }

  // 表单样式覆盖
  .ant-form-item-label>label {
    color: @dark-text;
  }

  // 菜单样式
  .ant-menu {
    background-color: @dark-bg-secondary;
    color: @dark-text;

    .ant-menu-item {
      color: @dark-text-tertiary;

      &:hover {
        background-color: rgba(255, 255, 255, 0.05);
        color: @dark-text;
      }

      &.ant-menu-item-selected {
        background-color: @dark-bg-tertiary;
        color: @primary-color;
      }
    }

    .ant-menu-submenu-title {
      color: @dark-text-tertiary;

      &:hover {
        background-color: rgba(255, 255, 255, 0.05);
        color: @dark-text;
      }
    }
  }

  // 下拉菜单样式
  .ant-dropdown-menu {
    background-color: @dark-bg-secondary;
    border: 1px solid #333;

    .ant-dropdown-menu-item {
      color: @dark-text;

      &:hover {
        background-color: @dark-bg-tertiary;
      }
    }
  }

  // 模态框样式
  .ant-modal {
    .ant-modal-content {
      background-color: @dark-bg-secondary;
      border: 1px solid #333;

      .ant-modal-header {
        border-bottom: 1px solid #333;

        .ant-modal-title {
          background-color: @dark-bg-secondary;
          color: @dark-text;
        }
      }

      .ant-modal-body {
        color: @dark-text-secondary;
      }

      .ant-modal-footer {
        border-top: 1px solid #333;
      }
    }
  }

  // 提示框样式
  .ant-tooltip {
    .ant-tooltip-inner {
      background-color: @dark-bg-tertiary;
      border: 1px solid #333;
      color: @dark-text;
    }
  }

  .ant-pagination-total-text {
    color: rgba(229, 224, 216, 0.85);
  }

  .ant-pagination .ant-pagination-item-active {
    background-color: @dark-bg-tertiary !important;
    border-color: #444 !important;
    color: rgba(229, 224, 216, 0.85) !important;
  }

  // 选择器样式
  .ant-select {
    .ant-select-selector {
      background-color: @dark-bg-tertiary !important;
      border-color: #444 !important;
      color: @dark-text !important;
    }

    .ant-select-dropdown {
      background-color: @dark-bg-secondary !important;
      border: 1px solid #333 !important;

      .ant-select-item {
        color: @dark-text !important;
        background-color: @dark-bg-tertiary !important;

        &:hover {
          background-color: @dark-bg-tertiary !important;
        }

        &.ant-select-item-selected {
          background-color: @dark-bg-tertiary !important;
        }
      }
    }
  }

  .ant-select-dropdown {
    color: rgba(229, 224, 216, 0.85);
    list-style-image: initial;
    background-color: rgb(36, 37, 37);
    outline-color: initial;
    box-shadow: rgba(13, 13, 13, 0.12) 0px 3px 6px -4px, rgba(13, 13, 13, 0.08) 0px 6px 16px 0px, rgba(13, 13, 13, 0.05) 0px 9px 28px 8px;

    .ant-select-item {
      color: rgba(229, 224, 216, 0.85);
      &.ant-select-item-option-active{
        background-color: @dark-bg-tertiary !important;
      }
      &.ant-select-item-option-selected {
        background-color: @dark-bg-tertiary !important;
      }
    }
  }


  // 文章创建和编辑页面暗黑模式样式
  .article-edit-container {
    background-color: @dark-bg;
    color: @dark-text;

    .page-header {
      background-color: @dark-bg-secondary !important;
      color: @dark-text;
      border-bottom: 1px solid #333;
    }

    .edit-content {
      background-color: @dark-bg;
      color: @dark-text;
    }

    .article-form {
      background-color: @dark-bg-secondary;
      padding: 20px;
      border-radius: 8px;
      border: 1px solid #333;
      color: @dark-text;
    }

    .form-section {
      background-color: @dark-bg-secondary;
      border-radius: 8px;
      padding: 16px 0;
      margin-bottom: 24px;
    }

    .section-header {
      margin-bottom: 16px;
      color: @dark-text;
    }

    .section-title {
      color: @dark-text !important;
      margin-bottom: 8px;
    }

    .section-desc {
      color: @dark-text-tertiary;
      font-size: 14px;
    }

    .editor-wrapper {
      background-color: @dark-bg-tertiary;
      border-radius: 8px;
      border: 1px solid #444;
      overflow: hidden;
    }

    .editor-toolbar {
      background-color: @dark-bg-tertiary;
      border-bottom: 1px solid #444;
      padding: 12px 16px;
      color: @dark-text-secondary;
    }

    .toolbar-info {
      color: @dark-text-tertiary;
    }

    .markdown-editor-container {
      background-color: @dark-bg-tertiary;
      color: @dark-text;
    }

    .enhanced-editor {
      background-color: @dark-bg-tertiary !important;
      color: @dark-text !important;
    }

    // 富文本编辑器(v-md-editor)暗黑模式完整样式


    .radio-desc {
      color: @dark-text-tertiary;
    }

    // 状态选择按钮暗黑模式样式
    .status-radio-group {
      .ant-radio-button-wrapper {
        background-color: @dark-bg-tertiary;
        border-color: #444;
        color: @dark-text-secondary;

        &:not(:first-child)::before {
          background-color: #444;
        }

        &:hover {
          color: @dark-text;
          border-color: #555;
        }

        &.ant-radio-button-wrapper-checked {
          color: @white;
          background-color: @primary-color;
          border-color: @primary-color;

          &:hover {
            color: @white;
            background-color: @primary-color-hover;
            border-color: @primary-color-hover;
          }
        }
      }

      // 草稿按钮特定样式
      .radio-draft {
        .anticon {
          color: @dark-text-tertiary;
        }

        &.ant-radio-button-wrapper-checked {
          .anticon {
            color: @white;
          }
        }
      }

      // 发布按钮特定样式
      .radio-publish {
        .anticon {
          color: @dark-text-tertiary;
        }

        &.ant-radio-button-wrapper-checked {
          .anticon {
            color: @white;
          }
        }
      }
    }

    .form-actions {
      background-color: @dark-bg-secondary;
      padding-top: 20px;
      border-top: 1px solid #333;
    }

    .action-buttons {
      display: flex;
      gap: 12px;
    }

    .input-icon,
    .textarea-icon,
    .option-icon {
      color: @dark-text-tertiary;
    }

    .category-option,
    .tag-option {
      color: @dark-text;
    }

    .edit-image-preview {
      border: 1px solid #333;
    }

    // 预览弹窗样式
    .preview-modal-container {
      background: #141414 !important;
    }

    .preview-toolbar {
      background: rgba(20, 20, 20, 0.9) !important;
      border-bottom: 1px solid #444 !important;
    }

    .preview-title {
      color: #e5e0d8 !important;
    }

    .preview-actions .ant-btn {
      color: #e5e0d8 !important;
    }

    .preview-actions .ant-btn:hover {
      color: #1890ff !important;
      background: rgba(255, 255, 255, 0.15) !important;
    }

    .preview-hint {
      background: rgba(20, 20, 20, 0.8) !important;
      color: #e5e0d8 !important;
    }
  }

  .personal-info-container {
    .contact-methods-section {
      .contact-method-item {
        background-color: @dark-bg-tertiary !important;
      }
    }

    .editor-toolbar {
      background-color: @dark-bg-tertiary !important;
      border-bottom: 1px solid #444 !important;
      padding: 12px 16px !important;
      color: @dark-text-secondary !important;
    }

    .markdown-editor-container {
      border: none !important;
      border-radius: 0 !important;
    }
  }
}